import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import electron from 'vite-plugin-electron/simple';

import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    vue(),
    electron({
      main: {
        entry: [
          'src/electron/ipc-render.ts',
          'src/electron/main.ts',
          'src/electron/whatsapp_injection.ts',
        ],
      },
      preload: {
        input: __dirname + '/src/electron/preload.ts',
      },
    }),
    AutoImport({
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/, // .md
      ],
      resolvers: [ElementPlusResolver()],
      imports: ['vue', 'pinia', 'vue-router', '@vueuse/core'],
      dirs: ['./src/composables', './src/store'],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
});
